import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class DBManagement {
	
	private final static String drv= "org.postgresql.Driver";
	private final static String db= "jdbc:postgresql://localhost:5432/postgres";
	private final static String userAndPass = "postgres";
	
	private Connection ct;
	private Statement st;
	
	public DBManagement ()
	{
		try
		{
			Class.forName(drv);
			ct = DriverManager.getConnection(db, userAndPass, userAndPass);
			st =ct.createStatement();
			System.out.println("Conexion exitosa.");
		}
		catch (Exception e)
		{
			System.out.println("Error de la base de datos.");
		}
	}
	
	public void showAll ()
	{
		try {
			ResultSet rs= st.executeQuery("select * from tarjeta");
			while(rs.next())
			{
				System.out.println(rs.getString(1)+"--");
			}
		} catch (Exception e) {
			System.out.println("ERROR");
		}
	}

}
